<template>
  <div class="exhibits-content" :style="{ width: props.info.width + 'rem', height: props.info.height + 'rem' }">
    <div
      class="decorate"
      :style="{
        'background-image': `url(${publicUrls + 'free/style1/exhibitionStandStyle1zs.webp'})`,
      }"
    ></div>
    <div
      @contextmenu.stop="emit('onContextMenuChild', $event, index)"
      v-for="(item, index) in props.info.showpieceList"
      :key="index"
      class="exhibits-item"
      :class="{ 'exhibits-item-2': (index + 1) % 2 === 0 }"
    >
      <div
        class="item-content"
        :style="{
          'background-image':
            (index + 1) % 2 === 0
              ? `url(${publicUrls + 'free/style1/exhibitionStandStyle1ItemRight.webp'})`
              : `url(${publicUrls + 'free/style1/exhibitionStandStyle1ItemLeft.webp'})`,
        }"
      >
        <div class="cover-box" @click="viewImg(item.moduleId, item.id)">
          <img class="cover" v-lazy="getLinkUrl(item.coverUrl, '?imageView2/3/w/600/format/webp')" alt="" />
          <img class="flower-btn" v-lazy="publicUrls + 'free/style1/flower.png?imageView2/format/webp'" />
          <p>{{ item.name }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'style1',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { DraggableContainer } from 'vue3-draggable-resizable';
// import FlotMenu from '@/components/flotMenu/OutlineMenu.vue';
import ContextMenu from '@imengyu/vue3-context-menu';
import { getDraggableNumber, getExhibitsHeightRest, getdisabledY } from '@/utils/getRemComputed';
import { ref, reactive, watch, nextTick, defineComponent } from 'vue';
import { exbitMenuShow, exbitListMenuShow } from '@/hooks/menuHooks';
import { useProjectStore } from '@/store';
import { getLinkUrl } from '@/utils/request/upload';

const emit = defineEmits([
  'emitChildItemDraggable',
  'emitChildItemDraggableStyle',
  'emitShowcaseDraggable',
  'emitShowcaseDraggableStyle',
  'onContextMenuChild',
]);
const store = useProjectStore();
const contextMenuTrigger = ref(); //列表盒子dom
const parentLock = ref(true);
const childShow = ref(true);
const draggableResizable = ref(); //父级拖拽盒子ref
const timer = ref();
const ImgVisible = ref(false);
const ImgUrl = ref('');

const props = defineProps({
  width: {
    type: Number || String,
  },
  height: {
    type: Number || String,
  },
  indexs: {
    type: Number,
  },
  info: {
    type: Object,
  },
  childId: {
    type: Number,
  },
  AuxiliaryId: {
    type: Number,
  },
});

const viewImg = (moduleId: number, e?: number) => {
  store.exhibitsModuleId = moduleId;
  store.exhibitsShowpieceid = e;
  store.exhibitsInfoShow = true;
};

const handleMouseDown = (event) => {
  event.stopPropagation();
};
const preventDefaultDrag = (event) => {
  event.stopPropagation();
};
// watch(
//   () => props.info.width,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );
// watch(
//   () => props.info.height,
//   () => {
//     childShow.value = false;
//     nextTick(() => {
//       childShow.value = true;
//     });
//   },
//   { deep: true },
// );

//
</script>

<style lang="less" scoped>
.exhibits-content {
  position: relative;
  display: flex;
  z-index: 999;
  padding: 0 !important;
}

.active {
  :deep(.flot-menu) {
    display: flex;
  }
}
:deep(.active) {
  z-index: 999;
}
:deep(.vdr-handle) {
  z-index: 66;
}
.exhibits-item {
  display: flex;
  align-items: flex-end;
  width: 178px;
  height: 644px;
  margin-right: 20px;
  &:nth-child(even) {
    -webkit-box-reflect: below 0% linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25));
  }
  &:nth-child(odd) {
    -webkit-box-reflect: below -5% linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25));
  }
  .item-content {
    width: 170px;
    height: 580px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-right: 6px;
    &:hover > .cover-box > .flower-btn {
      display: none;
    }
    .cover-box {
      width: 130px;
      position: relative;
      // &:hover {
      //   .flower-btn {
      //     display: none;
      //   }
      // }
      .cover {
        width: 100%;
        height: 197px;
        object-fit: contain;
        background: #f2e9d8;
        // box-shadow: 90, 76, 66, 0.39;
      }
      .flower-btn {
        width: 40px;
        height: 40px;
        object-fit: cover;
        position: absolute;
        top: 40%;
        left: 50%;
        transform: translate(-50%, -40%);
        animation: flower 2s linear infinite;
        @keyframes flower {
          0% {
            opacity: 0;
          }
          40% {
            opacity: 100%;
          }
          80% {
            opacity: 100%;
          }
          100% {
            opacity: 0;
          }
        }
      }
      ::v-deep p {
        color: #fef3df;
        text-align: center;
        font-family: 'SourceHanSerifCN-Bold';
        font-size: 18px;
        line-height: 22px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        margin-top: 21px;
      }
    }
  }
}
.exhibits-item-2 {
  display: flex;
  align-items: flex-start;
  width: 176px;
  height: 644px;
  margin-right: 20px;
  .item-content {
    width: 176px;
    height: 479px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }
}

.decorate {
  width: 137px;
  height: 476px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin-top: 189px;
  margin-right: 24px;
  -webkit-box-reflect: below -3% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
</style>
